import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { DeviceBindEntity } from '../../entity/bind';
import { DeviceBindService } from '../../service/bind';
import { DeviceDeviceEntity } from '../../entity/device';
import { StoreStoreEntity } from '../../../store/entity/store';

/**
 * 设备绑定记录
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: DeviceBindEntity,
  service: DeviceBindService,
  pageQueryOp: {
    select: ['a.*', 'b.deviceName', 'b.deviceNo', 'c.storeName'],
    join: [
      {
        entity: DeviceDeviceEntity,
        alias: 'b',
        condition: 'a.deviceId = b.id',
      },
      {
        entity: StoreStoreEntity,
        alias: 'c',
        condition: 'a.storeId = c.id',
      },
    ],
  },
})
export class AdminDeviceBindController extends BaseController {
  @Inject()
  deviceBindService: DeviceBindService;
}